package com.bdqn.t350.ch02.dao;

import com.bdqn.t350.ch02.pojo.User;
import org.hibernate.annotations.SQLInsert;
import org.hibernate.query.NativeQuery;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

public interface UserRepository extends JpaRepository<User, Long>, JpaSpecificationExecutor {

    @Transactional
    @Modifying
    @Query("update User set usrName=?2 where usrId = ?1")
    public int update(Long id, String uname);


    @Transactional
    @Modifying
    @Query(nativeQuery = true, value = "update sys_user set usr_name=?2 where usr_id = ?1")
    public int update1(Long id, String uname);

    public List<User> findByUsrNameAndUsrPassword(String usrName, String usrPassword);
    
}
